<?php

/**
 * This is the model class for table "profiles".
 *
 * The followings are the available columns in table 'profiles':
 * @property integer $profile_id
 * @property integer $user_id
 * @property string $first_name
 * @property string $last_name
 * @property string $birthdate
 * @property string $gender
 * @property string $bio
 * @property string $country
 * @property string $state
 * @property string $city
 * @property string $address
 * @property string $phone
 * @property string $telephone
 * @property string $mobile
 * @property string $postcode
 * @property integer $seeking
 * @property string $looking
 * @property integer $tall
 * @property integer $hair_color
 * @property integer $eyes_color
 * @property integer $ethnicity
 * @property integer $body_type
 * @property integer $marial_status
 * @property integer $children
 * @property integer $children_living
 * @property integer $smoke
 * @property integer $income
 * @property integer $education
 * @property integer $political_affiliation
 * @property integer $religion
 * @property integer $occupation
 * @property string $webpage
 * @property string $timezone
 * @property string $language
 * @property integer $login_attempts
 */
class Profile extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Profile the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{profiles}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('profile_id, user_id, seeking, tall, hair_color, eyes_color, ethnicity, body_type, marial_status, children, children_living, smoke, income, education, political_affiliation, religion, occupation, login_attempts', 'numerical', 'integerOnly'=>true),
			array('first_name, last_name', 'length', 'max'=>25),
			array('gender', 'length', 'max'=>6),
			array('country, state, city, telephone, mobile, timezone', 'length', 'max'=>45),
			array('address, looking, webpage', 'length', 'max'=>255),
			array('phone, postcode', 'length', 'max'=>15),
			array('language', 'length', 'max'=>10),
			array('birthdate, bio', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('profile_id, user_id, first_name, last_name, birthdate, gender, bio, country, state, city, address, phone, telephone, mobile, postcode, seeking, looking, tall, hair_color, eyes_color, ethnicity, body_type, marial_status, children, children_living, smoke, income, education, political_affiliation, religion, occupation, webpage, timezone, language, login_attempts', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
//                  'profile' => array(self::BELONGS_TO, 'Profile', '')
                  
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'profile_id' => 'Profile',
			'user_id' => 'User',
			'first_name' => 'First Name',
			'last_name' => 'Last Name',
			'birthdate' => 'Birthdate',
			'gender' => 'Gender',
			'bio' => 'Bio',
			'country' => 'Country',
			'state' => 'State',
			'city' => 'City',
			'address' => 'Address',
			'phone' => 'Phone',
			'telephone' => 'Telephone',
			'mobile' => 'Mobile',
			'postcode' => 'Postcode',
			'seeking' => 'Seeking',
			'looking' => 'Looking',
			'tall' => 'Tall',
			'hair_color' => 'Hair Color',
			'eyes_color' => 'Eyes Color',
			'ethnicity' => 'Ethnicity',
			'body_type' => 'Body Type',
			'marial_status' => 'Marial Status',
			'children' => 'Children',
			'children_living' => 'Children Living',
			'smoke' => 'Smoke',
			'income' => 'Income',
			'education' => 'Education',
			'political_affiliation' => 'Political Affiliation',
			'religion' => 'Religion',
			'occupation' => 'Occupation',
			'webpage' => 'Webpage',
			'timezone' => 'Timezone',
			'language' => 'Language',
			'login_attempts' => 'Login Attempts',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('profile_id',$this->profile_id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('first_name',$this->first_name,true);
		$criteria->compare('last_name',$this->last_name,true);
		$criteria->compare('birthdate',$this->birthdate,true);
		$criteria->compare('gender',$this->gender,true);
		$criteria->compare('bio',$this->bio,true);
		$criteria->compare('country',$this->country,true);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('telephone',$this->telephone,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('postcode',$this->postcode,true);
		$criteria->compare('seeking',$this->seeking);
		$criteria->compare('looking',$this->looking,true);
		$criteria->compare('tall',$this->tall);
		$criteria->compare('hair_color',$this->hair_color);
		$criteria->compare('eyes_color',$this->eyes_color);
		$criteria->compare('ethnicity',$this->ethnicity);
		$criteria->compare('body_type',$this->body_type);
		$criteria->compare('marial_status',$this->marial_status);
		$criteria->compare('children',$this->children);
		$criteria->compare('children_living',$this->children_living);
		$criteria->compare('smoke',$this->smoke);
		$criteria->compare('income',$this->income);
		$criteria->compare('education',$this->education);
		$criteria->compare('political_affiliation',$this->political_affiliation);
		$criteria->compare('religion',$this->religion);
		$criteria->compare('occupation',$this->occupation);
		$criteria->compare('webpage',$this->webpage,true);
		$criteria->compare('timezone',$this->timezone,true);
		$criteria->compare('language',$this->language,true);
		$criteria->compare('login_attempts',$this->login_attempts);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}